#include <cstdio>
#include <iostream>
using namespace std;
const int N = 1e6 + 10;
long long int a[N];
long long int n, m;
bool check(int mid)
{
    long long int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] > mid)
            ans += a[i] - mid;
    }
    if (ans >= m)
        return true;
    else
        return false;
}
int main(void)
{
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int l = 0, r = 1e9;
    while (l < r)
    {
        int mid = l + r + 1 >> 1;
        if (check(mid))
            l = mid;
        else
            r = mid - 1;
    }
    cout << r << endl;
    return 0;
}